//
//  EmailForgotPasswordViewController.m
//  insyte
//
//  Created by Vu Dang Tuan on 6/19/15.
//  Copyright (c) 2015 Robert. All rights reserved.
//

#import "EmailForgotPasswordViewController.h"
#import "Helpers.h"
#import "UIColor+InsyteColors.h"

@interface EmailForgotPasswordViewController ()<UITextFieldDelegate>

@end

@implementation EmailForgotPasswordViewController
{
    float _yAs;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpNavigationBar];
    [Helpers StyleButtonWithBorderColor:_btnSubmit color:[UIColor loginButtonColor] corner:0];
    [Helpers StyleViewWithBorderColor:_viewEmail color:[UIColor textfieldBorderColor] corner:0];
    _tfEmail.delegate = self;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
                                   initWithTarget:self
                                   action:@selector(dismissKeyboard)];
    
    [self.view addGestureRecognizer:tap];
    
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
    _yAs = self.view.frame.origin.y;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)setUpNavigationBar{
    UIBarButtonItem *btnBack = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_back"] style:UIBarButtonItemStylePlain target:self action:@selector(OnBackClicked)];
    self.navigationItem.leftBarButtonItem = btnBack;
    self.navigationItem.titleView = nil;
}

- (void) OnBackClicked{
    [self.navigationController popViewControllerAnimated:YES];
}



- (IBAction)OnSubmitClicked:(id)sender {
    
}



#pragma keyboard

- (void)keyboardDidHide: (NSNotification *) notif{
    [Helpers scrollView:self.view y:_yAs];
}
#pragma Textfield delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    [Helpers scrollView:self.view y:_yAs - 150];
    return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
-(void)dismissKeyboard {
    [self.tfEmail resignFirstResponder];
}
@end
